// 导入基础依赖
import Vue from 'vue';
import App from './App.vue';

import VXETable from 'vxe-table';
import 'vxe-table/lib/style.css';
// 导入第三方插件和组件库
import Element from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import Avue from '@smallwei/avue';
// 导入样式文件
import '@smallwei/avue/lib/index.css';

// 导入自定义工具函数
import { loadStyle } from './utils/loadStyle.js';

// 导入自定义组件
import modelIndex from "@/components/table/model/model-index";
import olDictTag from "@/components/ol-dict-tag.vue";
import olSelectDom from "@/components/ol-select-dom.vue";
import olTable from "@/components/table/ol-table/index.vue";
import olTableSearch from "@/components/table/ol-table-search/index.vue";

// 导入 Vuex 存储
import store from './store';

// 加载外部样式
try {
  loadStyle();
} catch (error) {
  console.error('加载外部样式时出错:', error);
}

// 配置 VXETable
VXETable.setup({
  version: 0,
  zIndex: 99999
});

// 使用插件和组件库
Vue.use(Avue, {
  size: 'mini'
});

Vue.use(Element, {
  size: 'mini' // 设置 element-ui 默认大小
});

Vue.use(VXETable);

// 注册全局组件
const globalComponents = {
  olDictTag,
  olSelectDom,
  olTable,
  olTableSearch,
  OTable: modelIndex
};

Object.entries(globalComponents).forEach(([name, component]) => {
  Vue.component(name, component);
});

// 关闭生产环境提示
Vue.config.productionTip = false;

// 创建并挂载 Vue 实例
new Vue({
  store,
  render: h => h(App),
}).$mount('#app');
